﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///FAQ 的摘要说明
/// </summary>
public partial class FAQ

{

     DataTableDataContext db = new DataTableDataContext();
     
    //返回所有公告信息
     public IEnumerable<FAQ> returnfaq()
     {
         var faq = from b in db.FAQ select b;
         return faq;
     }

     public IEnumerable<FAQ> GetAll()
     {
         var FAQquestion = from b in db.FAQ select b;
         return FAQquestion;
     }
    
    //根据FAQId查找FAQ内容
     public IEnumerable<FAQ> GetFAQbyId(int id)
     {
         var FAQquestion = from b in db.FAQ where b.FAQId == id select b;

         return FAQquestion;
     }

     //增加FAQ
     public void InsertFAQ(string newquestion, string newanswer,
                           int hitnumber)
     {
         FAQ faq = new FAQ
         {

            
             question = newquestion,
             answer = newanswer,
             hitNum= hitnumber,

         };
         db.FAQ.InsertOnSubmit(faq);
         db.SubmitChanges();

     }

     //删除FAQ
     public void DeleteFAQ(int delfaqid)
     {
         var faqs = from b in db.FAQ where b.FAQId == delfaqid select b;
         foreach (var faq in faqs )
         {
             db.FAQ.DeleteOnSubmit(faq);
             db.SubmitChanges();
         }

     }
        
}